import request from './request'

// 获取字典类型列表
export const getDictTypeList = (params) => {
  return request({
    url: '/dictTypes',
    method: 'get',
    params
  })
}

// 获取字典数据列表
export const getDictDataList = (params) => {
  return request({
    url: '/dictItems',
    method: 'get',
    params
  })
}

// 根据字典类型获取字典数据
export const getDictDataByType = (params) => {
  return request({
    url: `/dictItems/dictType`,
    method: 'get',
    params
  })
}

// 获取单个字典类型信息
export const getDictTypeInfo = (id) => {
  return request({
    url: `/dictTypes/${id}`,
    method: 'get'
  })
}

// 获取单个字典数据信息
export const getDictDataInfo = (id) => {
  return request({
    url: `/dictItems/${id}`,
    method: 'get'
  })
}

// 创建字典类型
export const createDictType = (data) => {
  return request({
    url: '/dictTypes',
    method: 'post',
    data
  })
}

// 创建字典数据
export const createDictData = (data) => {
  return request({
    url: '/dictItems',
    method: 'post',
    data
  })
}

// 更新字典类型
export const updateDictType = (id, data) => {
  return request({
    url: `/dictTypes/${id}`,
    method: 'put',
    data
  })
}

// 更新字典数据
export const updateDictData = (id, data) => {
  return request({
    url: `/dictItems/${id}`,
    method: 'put',
    data
  })
}

// 删除字典类型
export const deleteDictType = (id) => {
  return request({
    url: `/dictTypes/${id}`,
    method: 'delete'
  })
}

// 删除字典数据
export const deleteDictData = (id) => {
  return request({
    url: `/dictItems/${id}`,
    method: 'delete'
  })
}